import LevelInitBase from "../LevelCommon/LevelInitBase";
import LevelControl9 from "../LevelControl/LevelControl9";
import RoomControl from "../LevelCommon/RoomControl";
import { utils } from "../../utils/CommonUtil";
import GamePropConst from "../../constant/GamePropConst";
import GamePropObj from "../Prefabs/InteractivObj/Common/GamePropObj";
import FocusParentObj from "../Prefabs/InteractivObj/Common/FocusParentObj";
import RotateObj from "../Prefabs/InteractivObj/Common/RotateObj";
import PhysPassLock from "../Prefabs/InteractivObj/PhysPassLock/PhysPassLock";
import PhysPassKey from "../Prefabs/InteractivObj/PhysPassLock/PhysPassKey";
import CallToLevel from "../Prefabs/CallToLevel";
import Gate from "../Prefabs/InteractivObj/Gate";
import EnumData from "../../Enum/EnumData";
import CoinMachine from "../Prefabs/InteractivObj/CoinMachine/CoinMachine";
import MoveObj from "../Prefabs/InteractivObj/Common/MoveObj";
import PasswordLock from "../Prefabs/InteractivObj/Password/PasswordLock";
import FocusMoreParentObj from "../Prefabs/InteractivObj/Common/FocusMoreParentObj";

export default class LevelInit9 extends LevelInitBase {
    private room1: Laya.Sprite3D;

    private container: Laya.Sprite3D;

    public startInitDetail() {
        this.levelRoot.addComponent(LevelControl9);
        this.room1 = this.LevelObjs.getChildByName("room1") as Laya.Sprite3D;
        this.room1.addComponent(RoomControl);
        this.container = this.room1.getChildByName("Container") as Laya.Sprite3D;
        let walls = this.room1.getChildByName("walls");

        let jinianpin = this.Scene.getChildByName("jinianpin");
        let GamePropObj_jinianpin = utils.CommonUtils.CustomAddComponent(jinianpin, GamePropObj) as GamePropObj;
        GamePropObj_jinianpin.gamePropId = 11;

        //#region wall1

        let wall1 = walls.getChildByName("wall1");
        let Roulette = wall1.getChildByName("Roulette");
        utils.CommonUtils.CustomAddComponent(Roulette, FocusParentObj);

        let head_Roulette = Roulette.getChildByName("head_Roulette");
        let RotateObj_head_Roulette = utils.CommonUtils.CustomAddComponent(head_Roulette, RotateObj) as RotateObj;
        RotateObj_head_Roulette.IsRotateOnce = true;
        RotateObj_head_Roulette.VoiceName = "openGate";
        RotateObj_head_Roulette.targetRotate = new Laya.Vector3(-140, 0, 0);

        let head_RouletteObj = head_Roulette.getChildByName("head_Roulette").getChildByName("head_Roulette");
        let GamePropObj_head_RouletteObj = utils.CommonUtils.CustomAddComponent(head_RouletteObj, GamePropObj) as GamePropObj;
        GamePropObj_head_RouletteObj.isNeedCallToLevel = true;
        GamePropObj_head_RouletteObj.gamePropId = 49;

        let physPassLock = head_RouletteObj.getChildByName("physPassLock");
        let PhysPassLock_physPassLock = utils.CommonUtils.CustomAddComponent(physPassLock, PhysPassLock) as PhysPassLock;
        PhysPassLock_physPassLock.correctPassInde.push(5);
        PhysPassLock_physPassLock.correctPassInde.push(0);
        PhysPassLock_physPassLock.correctPassInde.push(2);
        PhysPassLock_physPassLock.correctPassInde.push(4);

        for (let index = 0; index < physPassLock.numChildren; index++) {
            var physicPassKeyObj = physPassLock.getChildAt(index);
            var physicPassKey = utils.CommonUtils.CustomAddComponent(physicPassKeyObj, PhysPassKey) as PhysPassKey;
            physicPassKey.rotateAngle = 60;
        }

        let bottom_Roulette = Roulette.getChildByName("bottom_Roulette");
        utils.CommonUtils.CustomAddComponent(bottom_Roulette, CallToLevel);

        let rouletCoin = Roulette.getChildByName("rouletCoin");
        let GamePropObj_rouletCoin = utils.CommonUtils.CustomAddComponent(rouletCoin, GamePropObj) as GamePropObj;
        GamePropObj_rouletCoin.isNeedCallToLevel = true;
        GamePropObj_rouletCoin.gamePropId = 48;

        let SM_Prop_Table_003 = wall1.getChildByName("SM_Prop_Table_003");
        utils.CommonUtils.CustomAddComponent(SM_Prop_Table_003, FocusParentObj);

        let SM_Prop_ShopInterior_Shelf_01 = wall1.getChildByName("SM_Prop_ShopInterior_Shelf_01");
        utils.CommonUtils.CustomAddComponent(SM_Prop_ShopInterior_Shelf_01, FocusParentObj);

        let SM_Item_Bottle_01 = SM_Prop_ShopInterior_Shelf_01.getChildByName("SM_Item_Bottle_01");
        let GamePropObj_SM_Item_Bottle_01 = utils.CommonUtils.CustomAddComponent(SM_Item_Bottle_01, GamePropObj) as GamePropObj;
        GamePropObj_SM_Item_Bottle_01.gamePropId = 43;

        let jinianpin1 = SM_Prop_ShopInterior_Shelf_01.getChildByName("jinianpin (1)");
        let GamePropObj_jinianpin1 = utils.CommonUtils.CustomAddComponent(jinianpin1, GamePropObj);
        GamePropObj_jinianpin1.gamePropId = 11;


        //#endregion

        //#region wall2

        let wall2 = walls.getChildByName("wall2");
        let ChamferBox001 = wall2.getChildByName("ChamferBox001");
        let GameObject1 = ChamferBox001.getChildByName("GameObject");
        utils.CommonUtils.CustomAddComponent(GameObject1, FocusParentObj);

        let burnWood = GameObject1.getChildByName("burnWood");
        utils.CommonUtils.CustomAddComponent(burnWood, CallToLevel);

        let fire = GameObject1.getChildByName("fire");
        utils.CommonUtils.CustomAddComponent(fire, CallToLevel);

        let wood = GameObject1.getChildByName("wood");
        utils.CommonUtils.CustomAddComponent(wood, CallToLevel);

        let GameObject2 = ChamferBox001.getChildAt(1);
        utils.CommonUtils.CustomAddComponent(GameObject2, FocusParentObj);

        let matches_prop = GameObject2.getChildByName("matches_prop");
        let GamePropObj_matches_prop = utils.CommonUtils.CustomAddComponent(matches_prop, GamePropObj) as GamePropObj;
        GamePropObj_matches_prop.gamePropId = 46;


        //#endregion

        //#region wall3

        let wall3 = walls.getChildByName("wall3");

        let SM_Bld_Bunker_Wall_Caution_Door_Opening_01 = wall3.getChildByName("SM_Bld_Bunker_Wall_Caution_Door_01").
            getChildByName("SM_Bld_Bunker_Wall_Caution_Door_Opening_01");

        let Gate_SM_Bld_Bunker_Wall_Caution_Door_Opening_01 = utils.CommonUtils.CustomAddComponent(SM_Bld_Bunker_Wall_Caution_Door_Opening_01, Gate) as Gate;
        Gate_SM_Bld_Bunker_Wall_Caution_Door_Opening_01.needPropId = 1111;
        Gate_SM_Bld_Bunker_Wall_Caution_Door_Opening_01.Axis = EnumData.Axis.Y;
        Gate_SM_Bld_Bunker_Wall_Caution_Door_Opening_01.Angle = -30;

        let coin_machine = wall3.getChildByName("coin_machine");
        utils.CommonUtils.CustomAddComponent(coin_machine, FocusParentObj);

        let coin_machineObj = coin_machine.getChildByName("coin_machine");
        let CoinMacthine_coin_machineObj = utils.CommonUtils.CustomAddComponent(coin_machineObj, CoinMachine) as CoinMachine;
        let coinPoses = coin_machineObj.getChildByName("coinPoses");
        for (let index = 0; index < coinPoses.numChildren; index++) {
            CoinMacthine_coin_machineObj.curAllCoin.push(coinPoses.getChildAt(index) as Laya.Sprite3D);
        }

        let gaizi = coin_machineObj.getChildByName("gaizi");
        let RotateObj_gaizi = utils.CommonUtils.CustomAddComponent(gaizi, RotateObj) as RotateObj;
        RotateObj_gaizi.IsRotateOnce = true;
        RotateObj_gaizi.targetRotate = new Laya.Vector3(0, 65, 0);
        RotateObj_gaizi.isConvertUnityRotation = true;
        

        let coinMachineBtn = coin_machineObj.getChildByName("coinMachineBtn");
        utils.CommonUtils.CustomAddComponent(coinMachineBtn, CallToLevel);


        //#endregion

        //#region wall4

        let wall4 = walls.getChildByName("wall4");

        let Box012 = wall4.getChildByName("Box012");
        utils.CommonUtils.CustomAddComponent(Box012, FocusParentObj);

        let Joystick = Box012.getChildByName("Joystick");
        let RotateObj_Joystick = utils.CommonUtils.CustomAddComponent(Joystick, RotateObj) as RotateObj;
        RotateObj_Joystick.IsRotateOnce = true;
        RotateObj_Joystick.targetRotate = new Laya.Vector3(0, 90, -90);
        RotateObj_Joystick.isNeedCallToLevel = true;
        RotateObj_Joystick.isConvertUnityRotation = true;

        let rili = Box012.getChildByName("rili");
        let MoveObj_rili = utils.CommonUtils.CustomAddComponent(rili, MoveObj) as MoveObj;
        MoveObj_rili.targetPos = new Laya.Vector3(1.252432, -4.47, -7.425394);

        let Plane009 = rili.getChildByName("Plane009");
        let GamePropObj_Plane009 = utils.CommonUtils.CustomAddComponent(Plane009, GamePropObj) as GamePropObj;
        GamePropObj_Plane009.gamePropId = 50;

        let rouletteCheck = Box012.getChildByName("rouletteCheck");
        utils.CommonUtils.CustomAddComponent(rouletteCheck, CallToLevel);

        let Plane005 = wall4.getChildByName("Plane005");
        utils.CommonUtils.CustomAddComponent(Plane005, FocusParentObj);

        let SM_Prop_Table_02 = wall4.getChildByName("SM_Prop_Table_02");
        utils.CommonUtils.CustomAddComponent(SM_Prop_Table_02, FocusParentObj);

        let rouletCoin_puke = wall4.getChildByName("rouletCoin_puke");
        let GamePropObj_rouletCoin_puke = utils.CommonUtils.CustomAddComponent(rouletCoin_puke, GamePropObj) as GamePropObj;
        GamePropObj_rouletCoin_puke.isNeedCallToLevel = true;
        GamePropObj_rouletCoin_puke.gamePropId = 48;

        let physFocus = wall4.getChildByName("physFocus");
        utils.CommonUtils.CustomAddComponent(physFocus, FocusParentObj);

        let physPassLock_puke = physFocus.getChildByName("physPassLock_puke");
        let PhysPassLock_physPassLock_puke = utils.CommonUtils.CustomAddComponent(physPassLock_puke, PhysPassLock) as PhysPassLock;
        PhysPassLock_physPassLock_puke.isDestroyEnd = true;
        PhysPassLock_physPassLock_puke.correctPassInde.push(6);
        PhysPassLock_physPassLock_puke.correctPassInde.push(5);
        PhysPassLock_physPassLock_puke.correctPassInde.push(2);

        for (let index = 0; index < physPassLock_puke.numChildren; index++) {
            let physicPassKeyObj = physPassLock_puke.getChildAt(index);
            if (index == 3) {
                utils.CommonUtils.CustomAddComponent(physicPassKeyObj, CallToLevel);
            } else {

                let physicPassKey = utils.CommonUtils.CustomAddComponent(physicPassKeyObj, PhysPassKey) as PhysPassKey;
                physicPassKey.rotateAngle = -45;
            }
        }

        let jinianpin2 = wall4.getChildByName("jinianpin (1)");

        let GamePropObj_jinianpin2 = utils.CommonUtils.CustomAddComponent(jinianpin2, GamePropObj) as GamePropObj;
        GamePropObj_jinianpin2.gamePropId = 11;

        //#endregion

        //#region Container
        let firstChessFocus = this.container.getChildByName("firstChessFocus");
        utils.CommonUtils.CustomAddComponent(firstChessFocus, FocusMoreParentObj);

        let firstChess = firstChessFocus.getChildByName("firstChess");
        let PhysPassLock_firstChess = utils.CommonUtils.CustomAddComponent(firstChess, PhysPassLock) as PhysPassLock;
        PhysPassLock_firstChess.isDestroyEnd = true;
        PhysPassLock_firstChess.correctPassInde.push(7);
        PhysPassLock_firstChess.correctPassInde.push(6);
        PhysPassLock_firstChess.correctPassInde.push(5);
        PhysPassLock_firstChess.correctPassInde.push(0);
        PhysPassLock_firstChess.correctPassInde.push(3);

        for (let index = 0; index < 5; index++) {
            let passwordObj = firstChess.getChildAt(index);
            let password = utils.CommonUtils.CustomAddComponent(passwordObj, PhysPassKey) as PhysPassKey;
            password.isRotateY = true;
            password.rotateAngle = -45;
        }

        let finalChess = this.container.getChildByName("finalChess").getChildByName("finalChess");
        utils.CommonUtils.CustomAddComponent(finalChess, FocusMoreParentObj);

        let GameObject1111 = finalChess.getChildByName("GameObject1111");
        utils.CommonUtils.CustomAddComponent(GameObject1111, FocusParentObj);

        let chess_side_Lock = GameObject1111.getChildByName("chess_side_Lock");
        let PhysPassLock_chess_side_Lock = utils.CommonUtils.CustomAddComponent(chess_side_Lock, PhysPassLock) as PhysPassLock;
        PhysPassLock_chess_side_Lock.isDestroyEnd = true;
        PhysPassLock_chess_side_Lock.correctPassInde.push(2);
        PhysPassLock_chess_side_Lock.correctPassInde.push(1);
        PhysPassLock_chess_side_Lock.correctPassInde.push(0);

        for (let index = 0; index < chess_side_Lock.numChildren; index++) {
            let passwordObj = chess_side_Lock.getChildAt(index);
            let password = utils.CommonUtils.CustomAddComponent(passwordObj, PhysPassKey) as PhysPassKey;
            password.rotateAngle = 60;
        }

        let finalChess_coin = this.container.getChildByName("finalChess").getChildByName("finalChess_coin");
        let GamePropObj_finalChess_coin = utils.CommonUtils.CustomAddComponent(finalChess_coin, GamePropObj) as GamePropObj;
        GamePropObj_finalChess_coin.isNeedCallToLevel = true;
        GamePropObj_finalChess_coin.gamePropId = 48;

        let gaizi2 = this.container.getChildByName("gaizi");
        utils.CommonUtils.CustomAddComponent(gaizi2, FocusMoreParentObj);

        let gaizi3 = gaizi2.getChildByName("gaizi");
        let RotateObj_gaizi3 = utils.CommonUtils.CustomAddComponent(gaizi3, RotateObj) as RotateObj;
        RotateObj_gaizi3.VoiceName = "openGate";
        RotateObj_gaizi3.targetRotate = new Laya.Vector3(90, 0, 0);
        RotateObj_gaizi3.IsRotateOnce = true;

        let gaiziCollier = gaizi3.getChildByName("gaiziCollier");
        utils.CommonUtils.CustomAddComponent(gaiziCollier, CallToLevel);

        let diaoxiang1 = this.container.getChildByName("diaoxiang1");
        utils.CommonUtils.CustomAddComponent(diaoxiang1, FocusMoreParentObj);

        let Plane002 = diaoxiang1.getChildByName("Plane002");
        let GamePropObj_Plane002 = utils.CommonUtils.CustomAddComponent(Plane002, GamePropObj) as GamePropObj;
        GamePropObj_Plane002.gamePropId = 44;

        let Plane008 = this.container.getChildByName("Plane008");
        utils.CommonUtils.CustomAddComponent(Plane008, FocusMoreParentObj);

        let SM_Item_Alcohol_01 = this.container.getChildByName("SM_Item_Alcohol_01");
        utils.CommonUtils.CustomAddComponent(SM_Item_Alcohol_01, FocusMoreParentObj);

        let SM_Prop_Crate_01 =  this.container.getChildByName("SM_Prop_Crate_01");
        let GamePropObj_SM_Prop_Crate_01 = utils.CommonUtils.CustomAddComponent(SM_Prop_Crate_01, GamePropObj) as GamePropObj;
        GamePropObj_SM_Prop_Crate_01.gamePropId = 47;

        let diaoxiang3 = this.container.getChildByName("diaoxiang3");
        utils.CommonUtils.CustomAddComponent(diaoxiang3, FocusMoreParentObj);

        let SM_Wep_Crowbar_01 =  diaoxiang3.getChildByName("SM_Wep_Crowbar_01");
        let GamePropObj_SM_Wep_Crowbar_01 = utils.CommonUtils.CustomAddComponent(SM_Wep_Crowbar_01, GamePropObj) as GamePropObj;
        GamePropObj_SM_Wep_Crowbar_01.gamePropId = 45;

        //#endregion
    }
}